<?php
namespace app\achievement\controller;

use app\common\model\AreasModel;
use app\common\model\CustomerLabelModel;
use app\common\model\CustomerModel;
use app\common\model\FollowModel;
use app\common\model\OaWorkersModel;

/**
 * Class Test
 * @package app\achievement\controller
 */
class Performance extends Base
{
    // 初始化构造方法
    public function __construct()
    {
        parent::__construct();

    }
    // 市场推广业绩列表
    public function index()
    {
        $this->assign('contract_number',input('param.contract_number'));
        return $this->fetch();
    }
    // 工程师傅业绩列表
    public function engineerslist()
    {
        $this->assign('contract_number',input('param.contract_number'));
        return $this->fetch();
    }

    // 渠道业绩列表
    public function channellist()
    {
        $this->assign('contract_number',input('param.contract_number'));
        return $this->fetch();
    }

    // 区县级承包商业绩列表
    public function adminlist()
    {
        $this->assign('contract_number',input('param.contract_number'));
        return $this->fetch();
    }


    /**
     * 结算关系
     * @author ligang
     * @date 2019/6/6 15:42
     */
    public function settlementrelations()
    {
        $is_admin = session($this->set['db_name'].'is_admin');
        if (!$is_admin){
            //获取当前用户权限
            $rule = session($this->set['db_name'] . 'rule');
            //限制
            $see = 0;
            $edit = 0;
            if (!empty($rule)){
                $rule = explode(',',$rule);
                if (in_array('327',$rule)){
                    $see = 1;
                }
                if (in_array('328',$rule)){
                    $edit = 1;
                }
            }
        }else{
            $see = 1;
            $edit = 1;
        }

        $this->assign('see',$see);
        $this->assign('edit',$edit);
        return $this->fetch();
    }

    /**
     * 结算关系详情
     * @author ligang
     * @return mixed
     * @date 2019/6/6 16:19
     */
    public function seesettlementrelations()
    {
        return $this->fetch();
    }

    /**
     * 编辑关系
     * @author ligang
     * @return mixed
     * @date 2019/6/6 16:19
     */
    public function editsettlementrelations()
    {
        $id = input('id') ?? '';
        $this->assign('id',$id);
        $is_admin = session($this->set['db_name'].'is_admin');
        if (!$is_admin){
            //获取当前用户权限
            $rule = session($this->set['db_name'] . 'rule');
            //限制
            $edit = 0;
            if (!empty($rule)){
                $rule = explode(',',$rule);
                if (in_array('328',$rule)){
                    $edit = 1;
                }
            }
        }else{
            $edit = 1;
        }

        $this->assign('edit',$edit);
        return $this->fetch();
    }

    //划拨
    public function transfer(){

        //获取当前用户权限
        $is_admin = session($this->set['db_name'] . 'is_admin');
        if (!$is_admin) {
            $rule = session($this->set['db_name'] . 'rule');
            //限制划拨
            $tempMoneyTransfer = false;
            if (!empty($rule)) {
                $rule = explode(',', $rule);
                if (in_array('322', $rule)) {
                    $tempMoneyTransfer = true;
                }
            }
        } else {
            $tempMoneyTransfer = true;
        }

        $this->assign('tempMoneyTransfer', $tempMoneyTransfer);

        return $this->fetch();
    }


    public function totalperformance(){
        $this->assign('contract_number',input('param.contract_number'));
        return $this->fetch();
    }





}
